package com.aisnow.entity.condition;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class PageCondition<M> {
    private Integer pageSize;
    private Integer pageNum;
    private String orderByColumn;
    private String isAsc;

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public String getOrderByColumn() {
        return orderByColumn;
    }

    public void setOrderByColumn(String orderByColumn) {
        this.orderByColumn = orderByColumn;
    }

    public String getIsAsc() {
        return isAsc;
    }

    public void setIsAsc(String isAsc) {
        this.isAsc = isAsc;
    }

    public Page<M> getPage() {
        Page<M> page = new Page<M>(pageNum, pageSize);
        if ("desc".equals(isAsc)) {
            page.setDesc(StringUtils.camelToUnderline(orderByColumn));
        } else {
            page.setAsc(StringUtils.camelToUnderline(orderByColumn));
        }
        return page;
    }
}
